package com.cg.asm.core.config.security;

import com.cg.asm.core.domain.vo.user.UserLoginVO;
import com.cg.asm.core.util.AsmApiUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Slf4j
public class CustomLogoutHandler implements LogoutHandler {
    @Override
    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        UserLoginVO userLoginVO = AsmApiUtils.getCurrentUserLoginVO();
        if (null != userLoginVO) {
            log.info("username: {}  is offline now", userLoginVO.getUsername());
        }
    }
}
